<template>
	<view class="container" :class="'theme-'+theme">
    <view class="addTitle" style="z-index: 999!important;">
      <view class="titleDetail">
        <view class="titleLeft" >
			<image src="../../static/newh5/fanhui.png"
			class="yticon"
			style="width: 13px;height: 20px;color:black"
			@click="returnIndex()"
			></image>
        </view>
        <view class="titleCenter" >
          <b class="titleText">创建订单</b>
        </view>
        <view class="titleRight"  style="color: #269cd3;flex:1" > </view>
      </view>
    </view>
		<!-- 地址 -->
		<navigator url="/pages/address/address?source=1" class="address-section">
			<view class="order-content">
				<text class="yticon icon-shouhuodizhi"></text>
				<view class="cen">
					<view class="top">
						<text class="name">{{addressData.consigneeName}}</text>
						<text class="mobile">{{addressData.mobile}}</text>
					</view>
					<text class="address">{{addressData.areaName}} {{addressData.addr}}</text>
				</view>
				<text class="yticon icon-you"></text>
			</view>
			<image class="a-bg" src="../../static/line.png"></image>
		</navigator>

		<view class="goods-section" v-for="(item,index) in orderList" :key="index">
			<view class="g-header b-b">
				<image class="logo" src="../../static/supplier-name.png" mode="aspectFill" v-if="supplierInfoShow"></image>
				<text class="name" v-if="supplierInfoShow">{{item.name}}</text>
        <u-image  v-if="item.protocolType=='eplus' && item.productLogo!=undefined && item.productLogo != ''"
                  :src="item.productLogo" width="128rpx" height="52rpx"></u-image>
				<text class="order" v-if="supplierInfoShow">订单{{index+1}}: {{item.protocolName}}</text>
			</view>
			<!-- 商品列表 -->
			<view class="g-item" v-for="(product,pIndex) in item.products">
				<image :src="product.thumbnail" @error="product.thumbnail = errorImgUrl"></image>
				<view class="right">
					<text class="title clamp">{{product.name}}</text>
					<text class="spec">{{product.catalogName}}</text>
					<view class="price-box">
						<text class="price">￥{{product.price|money}}</text>
						<text class="number">x {{product.num+product.unit}}</text>
					</view>
				</view>
			</view>
			<!-- 金额明细 -->
			<view class="yt-list">
				<!-- <view class="yt-list-cell">
					<text class="cell-tit clamp">优惠金额</text>
					<text class="cell-tip red" v-if="item.discountsum===0">无</text>
					<text class="cell-tip red" v-else>-￥{{item.discountsum|twoBitMoney}}</text>
				</view> -->
				<view class="yt-list-cell">
					<text class="cell-tit clamp">运费</text>
					<text class="cell-tip">{{item.freight===null||item.freight===''||item.freight==='Object'||item.freight===0?'免运费':item.freight+'元'}}</text>
				</view>

        <view class="yt-list-cell">
          <text class="cell-tit clamp">支付方式</text>
          <text class="cell-tip" @click="doPayMethodSelect(item)">{{item.payMethod.name}}</text>
          <text class="yticon cell-more icon-you" @click="doPayMethodSelect(item)"></text>
        </view>
				<view class="yt-list-cell desc-cell">
					<text class="cell-tit clamp">备注</text>
					<input class="desc" type="text" v-model="desc[index]" placeholder="请填写备注信息" placeholder-class="placeholder" />
				</view>
				<!-- 				<view class="yt-list-cell" v-if="item.payways.length>0">
					<text class="cell-tit clamp">支付方式</text>
					<radio-group @change="payWayOnChange(e,index)">
						<view v-for="(way,wayIndex) in item.payways">
							<radio style="transform:scale(0.7)" :checked="wayIndex===payWayIndexList[index]" :value="way.id">{{way.name}}</radio>
						</view>
					</radio-group>
				</view> -->
			</view>
			<template v-if="item.supplierDiscountSum>0">
				<view class="sum">
					<text class="sum-total-tit">总额：</text>
					<text class="sum-total-price">¥{{item.originalSubtotal|twoBitMoney}}</text>
				</view>
				<view class="sum">
					<text class="sum-total-tit">优惠：</text>
					<text class="sum-total-price">¥{{item.supplierDiscountSum|twoBitMoney}}</text>
					<text style="color: #d9001b;margin-left: 8rpx;" @click="clickDiscount(item)">明细</text>
				</view>
			</template>
			<view class="sum">
				<text class="sum-num">共{{item.num}}件</text>
				<text class="sum-total-tit">小计：</text>
				<text class="sum-total-price">￥{{item.subtotal| twoBitMoney}}</text>
			</view>
		</view>

    <!--预算关联商品-->
    <view class="settlement-section" v-if="orderBudget.openBudget">
      <view class="section-title">
        ——预算信息——
        <u-button v-if="!isAutoSelectBudget" class="right-button" :plain="true" :ripple="true" shape="circle" type="warning" size="mini"  @click="getBudgetData">添加预算</u-button>
      </view>
      <image class="a-bg" src="../../static/line.png"></image>
      <u-empty v-if="orderBudget.budgetList.length===0" mode="order" text="未选择预算" icon-size="80"></u-empty>
      <view v-if="orderBudget.budgetList.length>0" class="list b-b" style="overflow-y:auto;" v-for="item in orderBudget.budgetList" :key="item.id">
        <view class="wrapper">
          <view class="product-box">
            <text class="product" style="font-weight: bold;font-size: 32rpx">{{ item.budgetName }}</text>
          </view>
          <view class="product-box">
            <text class="product" v-if="item.budgetControllerType.indexOf('02')!=-1&&!item.infiniteNum">剩余数量:{{ item.budgetNum }} 使用数量:{{ item.num }}</text>
            <text class="product" v-else-if="item.budgetControllerType.indexOf('02')!=-1&&item.infiniteNum">剩余数量:{{ item.budgetNum }} 使用数量:{{ item.num }}</text>
            <text class="product" v-else>剩余数量:-- 使用数量:{{ item.num }}</text>
          </view>
          <view class="u-box">
            <text class="name" v-if="item.budgetControllerType.indexOf('01')!=-1&&!item.infiniteAmount">可用金额:￥{{ item.budgetBalance|twoBitMoney}}</text>
            <text class="name" v-else-if="item.budgetControllerType.indexOf('01')!=-1&&item.infiniteAmount">可用金额:无限</text>
            <text class="name" v-else>可用金额:--</text>
            <text class="mobile">使用金额:￥{{ item.amount|twoBitMoney }}</text>
          </view>
          <view class="bottom">
<!--            <view class="more"><u-icon name="more-dot-fill" color="rgb(203,203,203)"></u-icon></view>-->
            <view class="logistics btn" @click="getBudgetInfoDetail(item)">商品列表</view>
            <view class="exchange btn" v-if="!isAutoSelectBudget" @click="addBudgetInfoDetail(item)">添加商品</view>
            <view class="evaluate btn" v-if="!isAutoSelectBudget" @click="deleteBudgetInfo(item)">删除</view>
          </view>
        </view>
      </view>
      <u-cell-item v-if="orderBudget.budgetList.length>0" center :is-link="true" index="index"
                   :label-style="labelStyle" :title-style="titleStyle" :arrow="true"
                   :title="refBudget" :label="noneRefBudget" :value="total" :border-bottom="false" bg-color="#ffffff" @click="noRelationBudgetProductVisible = true">
      </u-cell-item>
    </view>

    <!-- 发票信息 -->
    <view class="settlement-section" v-if="showInvoice">
      <view class="yt-list">
        <view @click="invoiceShow ='show'" class="yt-list-cell" style="padding-left: 30rpx;line-height: 60rpx;padding-top: 0;">
          <!-- <view class="cell-icon">
              ~
            </view> -->
          <text class="cell-tit clamp">发票信息</text>
          <text class="cell-tip active">{{invoice.title}}</text>
          <text class="yticon cell-more icon-you"></text>
          <!-- <text class="cell-more wanjia wanjia-gengduo-d"></text> -->
        </view>
      </view>
    </view>

		<!-- 结算 -->
		<view class="settlement-section">
			<view class="yt-list">
				<view class="yt-list-cell" style="padding-left: 30rpx;line-height: 60rpx;padding-top: 0;">
					<text class="cell-tit clamp">商品总额</text>
					<text class="cell-tip red">￥{{orderData.originalTotal|money}}</text>
				</view>
				<view class="yt-list-cell" style="padding-left: 30rpx;line-height: 60rpx;">
					<text class="cell-tit clamp">运费共计</text>
					<text class="cell-tip red">￥{{orderData.freight|twoBitMoney}}</text>
				</view>
        <view v-if="showPrice" class="yt-list-cell" style="padding-left: 30rpx;line-height: 60rpx;">
          <text class="cell-tit clamp">服务费</text>
          <text class="cell-tip red">￥{{orderData.serviceFee|twoBitMoney}}</text>
        </view>
        <view v-if="showPrice" class="yt-list-cell" style="padding-left: 30rpx;line-height: 60rpx;">
          <text class="cell-tit clamp">优惠金额</text>
          <text class="cell-tip red">-￥{{orderData.preferentialFee|twoBitMoney}}</text>
        </view>
		<view class="yt-list-cell" style="padding-left: 30rpx;line-height: 60rpx;">
		    <text class="cell-tit clamp">店铺优惠</text>
		    <text class="cell-tip red">¥{{orderData.supplierDiscountSum|twoBitMoney}}</text>
		</view>
				<view class="yt-list-cell" style="padding-left: 30rpx;line-height: 60rpx;">
					<text class="cell-tit clamp">应付总额(含运费)</text>
<!--					<text class="cell-tip red" v-if="payWay==='积分支付'">{{orderData.total}} 积分</text>-->
					<text class="cell-tip red">￥{{(orderData.amount)| twoBitMoney}}</text>
				</view>
			</view>
		</view>

		<!-- 底部 -->
		<view class="footer">
			<view class="price-content">
				<text style="font-size: 14px;">实付款(含运费)</text>
<!--				 <text class="price-tip">￥</text>-->
				<text class="price">￥{{orderData.amount| twoBitMoney}}</text>
			</view>
			<text class="submit" @click="beforeSubmitOrder">
        <u-loading :disabled="orderCreateLoading" :show="orderCreateLoading" mode="flower" size="29"></u-loading>
        提交订单
      </text>
		</view>


    <!-- 发票信息面板 -->
    <view class="mask" :class="invoiceShow">
      <view class="invoice-content" @click.stop.prevent="stopPrevent">
        <view class="header">
          <view class="title">发票信息</view>
          <image src="../../static/close.png" class="close" @click="cancelInvoice()" />
        </view>
        <view class="payway-area">
          <view class="payway-item" :class="index===invoiceIndex?'active':''" v-for="(item,index) in invoiceList" @click="changeInvoice(item,index)"
                :key="index">
            {{item.name}}
          </view>
        </view>
        <scroll-view scroll-x class="integral-area"  v-show="invoiceList[invoiceIndex].name==='直接开票'">
          <view class="scroll-wrapper">
            <view class="integral-item" v-if="invoiceTypeList.length>0" :class="index===invoiceTypeIndex?'active':''" v-for="(invoice,index) in invoiceTypeList"
                  :key="index" @click="changeInvoiceType(invoice,index)">
              <text class="name huanhang">{{invoice.title}}</text>
              <text class="balance">{{invoiceType[invoice.invoiceType]}}</text>
            </view>
          </view>
        </scroll-view>
        <view v-if="supplierInfoShow">
        <view class="row b-b" v-if="isInvoice">
          <text class="tit">联系人</text>
          <input class="input" type="text" v-model="addressCopyData.consigneeName" placeholder="收货人姓名" placeholder-class="placeholder" />
        </view>
        <view class="row b-b" v-if="isInvoice">
          <text class="tit">手机号</text>
          <input class="input" type="number" v-model="addressCopyData.mobile" placeholder="收货人手机号码" placeholder-class="placeholder" />
        </view>
        <view class="row b-b" v-if="isInvoice">
          <text class="tit">地址</text>
          <!-- 			<text @click="chooseLocation" class="input">
            {{addressData.areaName}}
          </text> -->
          <view class="input" @click="toggleTab">{{(addressCopyData.areaName===null||addressCopyData.areaName===''||addressData.areaName===undefined)?'请选择收货地址':addressCopyData.areaName}}</view>
          <uni-popup ref="popup" type="bottom">
            <view class="popup">
              <view class="picker-btn">
                <view class="left" @click="cancel">取消</view>
                <view class="right" @click="confirmAddress">确定</view>
              </view>
              <picker-view :indicator-style="indicatorStyle" :value="valueArr" @change="bindChange">
                <picker-view-column>
                  <view class="item" v-for="(item,index) in province" :key="index">{{item.name}}</view>
                </picker-view-column>
                <picker-view-column>
                  <view class="item" v-for="(item,index) in province[valueArr[0]].children" :key="index">{{item.name}}</view>
                </picker-view-column>
                <picker-view-column>
                  <view class="item" v-for="(item,index) in province[valueArr[0]].children[valueArr[1]].children" :key="index">{{item.name}}</view>
                </picker-view-column>
                <picker-view-column>
                  <view class="item" v-for="(item,index) in province[valueArr[0]].children[valueArr[1]].children[valueArr[2]].children" :key="index">{{item.name}}</view>
                </picker-view-column>
              </picker-view>
            </view>
          </uni-popup>
          <!-- <text class="yticon icon-shouhuodizhi"></text> -->
        </view>
        <view class="row b-b" v-if="isInvoice">
          <text class="tit">详细地址</text>
          <input class="input" type="text" v-model="addressCopyData.addr" placeholder="楼号、门牌" placeholder-class="placeholder" />
        </view>
		<view v-if="isInvoice" style="display: flex;">
			<button class="add-btn themeBgColor" @click="sameConsignee">同收货人</button>
			<button class="add-btn themeBgColor" @click="cancelInvoice">确定</button>
		</view>
        </view>
      </view>
    </view>

    <!-- 支付方式面板 -->
    <view class="mask" :class="payMethodShow">
      <view class="mask-content" @click.stop.prevent="stopPrevent">
        <view class="header">
          <view class="title">支付方式</view>
          <image src="../../static/close.png" class="close" @click="payMethodShow = 'none'" />
        </view>
        <scroll-view scroll-x class="integral-area" >
          <view class="scroll-wrapper">
            <view class="integral-item" :class="index===payMethodIndex?'active':''" v-for="(item,index) in payMethodList"
                  :key="index" @click="changePayMethod(item,index)">
              <text class="name">{{item.name}}</text>
            </view>
          </view>
        </scroll-view>
        <view class="footer">
          <view class="confirm" @click="confirmPayMethod">确定</view>
        </view>
      </view>
    </view>

    <!--预算选择弹窗-->
    <u-popup mode="bottom" :mask="true" v-model="addBudgetVisible" border-radius="10" :closeable="true">
      <u-switch v-model="budgetChecked" @change="switchChange" size="35" :active-color="activeColor" style="position:absolute;margin-top: 12px;margin-left: 50rpx">是否全选</u-switch>
      <view class="budget-title">预算列表</view>
      <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @change="onSwiperChange" @animationfinish="animationfinish">
        <swiper-item class="swiper-item">
          <u-checkbox-group ref="testldb"  v-if="addBudgetData.length>0" @change="checkboxGroupChange" activeColor="#fa436a">
            <view class="list b-b" style="overflow-y:auto;border-radius: 20rpx;margin: 8rpx 0 8rpx" v-for="(item,index) in addBudgetData" :key="item.id">
              <u-checkbox @change="checkboxChange" v-model="item.checked" :name="item"></u-checkbox>
                <view class="wrapper">
                  <view class="product-box">
                    <text class="product" style="font-weight: bold;font-size: 32rpx">{{ item.name }}</text>
                  </view>
                  <view class="product-box">
                    <text class="product" v-if="!item.isInfiniteNum">
                      剩余数量:{{ item.budgetControllerType.indexOf("02")!=-1?(item.num-item.usedNum-item.occupyNum):"--" }} 采购目录:{{ item.budgetCatalogName||'--' }}
                    </text>
                    <text class="product" v-else>剩余数量:无限 采购目录:{{ item.budgetCatalogName||'--' }}</text>
                  </view>
                  <view class="product-box">
                    <text class="product" v-if="item.budgetControllerType.indexOf('01')!=-1&&!item.isInfiniteAmount">可用金额:<text style="color:#FA436A;display:inline">￥{{(item.amount-item.usedAmount-item.occupyAmount)| twoBitMoney}}</text></text>
                    <text class="product" v-else-if="item.budgetControllerType.indexOf('01')!=-1&&item.isInfiniteAmount">可用金额:<text style="color:#FA436A;display:inline">无限</text></text>
                    <text class="product" v-else>可用金额:--</text>
                  </view>
                  <view class="u-box">
                    <text class="name">预算日期范围:{{item.startTime}}~{{item.endTime}}</text>
                  </view>
                </view>
              </view>
          </u-checkbox-group>
          <u-empty v-else mode="order" text="暂无可选预算" icon-size="80">
          </u-empty>
        </swiper-item>
      </swiper>
      <view style="display: flex">
        <u-button :custom-style="buttonStyle" :ripple="true" shape="circle" @click="budgetSelectedConfirm" >确认</u-button>
        <u-button :custom-style="buttonStyle" :ripple="true" shape="circle" @click="budgetSelectedCancel">取消</u-button>
      </view>
    </u-popup>

    <!--已选择商品弹窗-->
    <u-popup border-radius="10" v-model="relationBudgetProductsVisible"
             mode="bottom" :mask="true"
             :closeable="false" :custom-style="customStyle">
      <u-tabs-swiper :show-bar="false" active-color="#fa436a" ref="tabs"
                     :active-item-style="activeItemStyle"
                     :list="produceList" :current="current" @change="onTabsChange"
                     :is-scroll="false"></u-tabs-swiper>
      <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @change="onSwiperChange" @animationfinish="animationfinish">
        <swiper-item class="swiper-item">
          <u-empty v-if="relationBudgetProducts.length===0" mode="order" text="暂无已关联商品" icon-size="80">
          </u-empty>
          <view class="order" v-for="(item,index) in relationBudgetProducts">
            <view class="item">
              <view class="left"><image :src="item.productThumbnail" @error="item.productThumbnail = errorImgUrl" mode="aspectFill"></image></view>
              <view class="content">
                <view class="title u-line-3">{{ item.productName }}</view>
              </view>
              <view class="right">
                <view class="price">
                  ￥{{item.salePrice | money}}
                </view>
                <view class="number">x{{ item.num }}</view>
              </view>
            </view>
            <view class="totalPrice">
              <view class="combine" v-if="refPreferential">小计(含服务费和优惠价):<view style="color: #fa436a;display: inline">￥{{getTotalPrice(item)}}{{item.showFreight >0 ?'（含运费）':''}}</view></view>
              <view class="price" v-else>小计:<view style="color: #fa436a;display: inline">￥{{getTotalPrice(item)}}{{item.showFreight >0 ?'（含运费）':''}}</view></view>
              <view class="uni-num-box">
                <view class="subtract" @click="refReduce(index)" :class="{disabled:item.relationNum <= 0||isAutoSelectBudget}"
                      @click.stop="item.relationNum <= 0">-</view>
                <input class="count" :disabled="isAutoSelectBudget" type="number" v-model="item.relationNum" @input="refNumChange(index,item.relationNum)"/>
                <view class="add" @click="refAddPlus(index)" :class="{disabled:item.relationNum >= item.currUsableRelationNum||isAutoSelectBudget}"
                      @click.stop="item.relationNum >= item.currBlanceNum">+</view>
              </view>
            </view>
          </view>
        </swiper-item>
      </swiper>
      <view style="display: flex" v-if="!isAutoSelectBudget">
        <u-button :custom-style="buttonStyle" :ripple="true" shape="circle" @click="productModalShow = true" >确认</u-button>
        <u-button :custom-style="buttonStyle" :ripple="true" shape="circle" @click="relationProductCancelBtnEvent">取消</u-button>
      </view>
    </u-popup>

    <!--未关联商品弹窗-->
    <u-popup border-radius="10" v-model="commodityVisible"
             mode="bottom" :mask="true"
             :closeable="false" :custom-style="customStyle">
      <u-tabs-swiper :show-bar="false" active-color="#fa436a" ref="tabs"
                     :active-item-style="activeItemStyle"
                     :list="noneRefProduceList" :current="current" @change="onTabsChange"
                     :is-scroll="false"></u-tabs-swiper>
      <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @change="onSwiperChange" @animationfinish="animationfinish">
        <swiper-item class="swiper-item">
          <u-empty v-if="commodityData.length===0" mode="order" text="暂无可关联商品" icon-size="80">
          </u-empty>
          <view class="order" v-for="(item,index) in commodityData">
            <view class="item">
              <view class="left">
                <image :src="item.productThumbnail" @error="item.productThumbnail = errorImgUrl" mode="aspectFill"></image>
<!--                <view class="yticon icon-xuanzhong2 checkbox" :class="'checked'" @click.stop="check('item',index,key)"></view>-->
              </view>
              <view class="content">
                <view class="title u-line-3">{{ item.productName }}</view>
              </view>
              <view class="right">
                <view class="price">
                  ￥{{item.salePrice | money}}
                </view>
                <view class="number">x{{ item.num }}</view>
              </view>
            </view>
            <view class="totalPrice">
<!--            <view style="display: flex;justify-content: space-between;">-->
              <view class="combine" v-if="noneRefPreferential">小计(含服务费和优惠价):
                <view class="price">￥{{getTotalPrice(item)}}{{item.showFreight >0 ?'（含运费）':''}}</view>
              </view>
              <view class="combine" v-else>小计:
                <view class="price">￥{{getTotalPrice(item)}}{{item.showFreight >0 ?'（含运费）':''}}</view>
              </view>
              <view class="uni-num-box">
                <view class="subtract" @click="noneRefReduce(index)" :class="{disabled:item.relationNum <= 0}"
                      @click.stop="item.relationNum <= 0">-</view>
                <input class="count" type="number" v-model="item.relationNum" @input="noneRefNumChange(index,item.relationNum)"/>
                <view class="add" @click="noneRefAddPlus(index)" :class="{disabled:item.relationNum >= item.currBlanceNum}"
                      @click.stop="item.relationNum >= item.currBlanceNum">+</view>
              </view>
            </view>
          </view>
        </swiper-item>
      </swiper>
      <view style="display: flex">
        <u-button :custom-style="buttonStyle" :ripple="true" shape="circle" @click="doAddBudgetInfoDetail" >确认</u-button>
        <u-button :custom-style="buttonStyle" :ripple="true" shape="circle" @click="commodityVisible = false">取消</u-button>
      </view>
    </u-popup>

    <!--未关联商品列表，-->
    <u-popup border-radius="10" v-model="noRelationBudgetProductVisible"
             mode="bottom" :mask="true"
             :closeable="false" :custom-style="customStyle">
      <u-tabs-swiper :show-bar="false" active-color="#fa436a" ref="tabs"
                     :active-item-style="activeItemStyle"
                     :list="noneRefProduceList" :current="current" @change="onTabsChange"
                     :is-scroll="false"></u-tabs-swiper>
      <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @change="onSwiperChange" @animationfinish="animationfinish">
        <swiper-item class="swiper-item">
          <u-empty v-if="noRelationBudgetProductList.length===0" mode="order" text="暂无可关联商品" icon-size="80">
          </u-empty>
          <view class="order" v-for="(item,index) in noRelationBudgetProductList">
            <view class="item">
              <view class="left"><image :src="item.productThumbnail" @error="item.productThumbnail = errorImgUrl" mode="aspectFill"></image></view>
              <view class="content">
                <view class="title u-line-3">{{ item.productName }}</view>
              </view>
              <view class="right">
                <view class="price">
                  ￥{{item.salePrice | money}}
                </view>
                <view class="number">x{{ item.num }}</view>
              </view>
            </view>
            <view class="totalPrice">
              <view class="combine" v-if="noneRefPreferential">小计(含服务费和优惠价):<view class="price">￥{{getTotalPrice(item)}}{{item.showFreight >0 ?'（含运费）':''}}</view></view>
              <view class="combine" v-else>小计:<view class="price">￥{{getTotalPrice(item)}}{{item.showFreight >0 ?'（含运费）':''}}</view></view>
              <view class="uni-num-box">
                <view>未关联数量:<view style="display: inline;font-size: 32rpx;font-weight: bold">{{ item.relationNum }}</view></view>
              </view>
            </view>
          </view>
        </swiper-item>
      </swiper>
    </u-popup>
    <!-- 审批流选择人弹窗 -->
    <u-popup v-model="approvalShow" class="approval-container" mode="bottom">
      <view class="title">
        请选择审批人
      </view>
      <view class="mode-choice-container">
        <u-radio-group active-color="#fa436a" v-model="approvalMode" @change="changeApprovalMode">
          <u-radio shape="circle" :name="0">或签审批</u-radio>
          <u-radio shape="circle" :name="1">指定人员</u-radio>
        </u-radio-group>
      </view>
      <view class="list-container">
      <u-checkbox-group
      active-color="#fa436a"
      style="width:100%;" @change="checkboxGroupChange">
        <u-row  v-for="(user,index) in approvalUserList" :key="index" class="select-container" style="width:100%;">
          <u-col span="10">
            <u-form :model="user">
              <u-form-item label="姓名：" :border-bottom="false" label-width="100">
                <text>{{user.userName}}</text>
              </u-form-item>
               <u-form-item label="职位：" :border-bottom="false" label-width="100">
                <text>{{user.postName}}</text>
              </u-form-item>
               <u-form-item label="部门：" :border-bottom="false" label-width="100">
                <text>{{user.fullDeptName}}</text>
              </u-form-item>
            </u-form>
            <!-- <u-row>
              <u-col span="3"><text class="font-title">姓名：</text></u-col>
              <u-col span="9"><view class="font-name">{{user.userName}}</view></u-col>
            </u-row>
            <u-row>
              <u-col span="3"><text class="font-title">职位：</text></u-col>
              <u-col span="9"><view class="font-job">{{user.postName}}</view></u-col>
            </u-row>
            <u-row>
              <u-col span="3"><text class="font-title">部门：</text></u-col>
              <u-col span="9"><view class="font-dept-name">{{user.fullDeptName}}</view></u-col>
            </u-row> -->
            <!-- <u-table>
              <u-tr>
                <u-td>姓名：</u-td>
                <u-td>{{user.userName}}</u-td>
              </u-tr>
              <u-tr>
                <u-td>职位：</u-td>
                <u-td>{{user.postName}}</u-td>
              </u-tr>
              <u-tr>
                <u-td>部门：</u-td>
                <u-td>{{user.fullDeptName}}</u-td>
              </u-tr>
            </u-table> -->
          </u-col>
          <u-col span="2" v-show="approvalMode === 1">
            <u-checkbox
            v-model="user.checked"
            ></u-checkbox>
          </u-col>
        </u-row>
      </u-checkbox-group>
      </view>
      <u-button  class="sure-button" :disabled="orderCreateLoading"  type="error" @click="confirmApproval" >
        <u-loading :show="orderCreateLoading" mode="flower" size="29"></u-loading>
        提交</u-button>
    </u-popup>


    <!--删除预算弹窗-->
    <u-modal ref="uModal" v-model="budgetModalShow" :show-cancel-button="true"
             :show-title="false" @confirm="budgetModalConfirm" content="是否删除该预算？">
    </u-modal>

    <u-modal ref="uModal" v-model="productModalShow" :show-cancel-button="true"
             :show-title="true" title="确认修改" @confirm="productModalConfirm" content="确认是否修改已关联商品数量？">
    </u-modal>

    <!--下单的预算不足校验弹窗-->
    <u-modal ref="uModal" v-model="preOrderModalShow" :show-cancel-button="true"
      :show-title="true" title="确认提交订单?" @confirm="preOrderModalConfirm" content="预算不足，是否继续下单？">
    </u-modal>
	<u-popup v-model="showDiscount" mode="bottom" height="70%" closeable>
		<marketing-discount :data="currentDiscount"/>
	</u-popup>
	</view>
</template>

<script>
import {  goback } from "@/common/utils/navigateBack.js";
import {
  getAddressList,
  getPreOrder,
  getOrderFeeInfo,
  createOrder,
  getBudgetList,
  doLoadingInvoiceList,
  getInvoiceType,
  getBudgetConf,
  addBudgetList,
  removeUserBudgetInfo,
  getCatalogNoRelationBudgetProducts,
  saveUserBudgetDetails,
  seeBudgetInfoDetail,
  getApprovalFlowByUser, loadAddr, loadChildAddr, updateAddr, setDefault, addAddr,loadChildAllAddr,
  getInvoiceConf,
  getAdminInvoice,
  isBlackPermissionV2
} from '../../api/order/order.js'
  import UTabsSwiper from "../../uview-ui/components/u-tabs-swiper/u-tabs-swiper";
  import UPopup from "../../uview-ui/components/u-popup/u-popup";
  import URadio from "../../uview-ui/components/u-radio/u-radio";
  import USwitch from "../../uview-ui/components/u-switch/u-switch";
  import UButton from "../../uview-ui/components/u-button/u-button";
  import UIcon from "../../uview-ui/components/u-icon/u-icon";
  import UCheckboxGroup from "../../uview-ui/components/u-checkbox-group/u-checkbox-group";
  import URow from "../../uview-ui/components/u-row/u-row";
  import {
    isEmpty
  } from '../../common/utils/func.js'
  import {
    errorImgUrl
  } from '@/common/utils/config.js';
  import UModal from "../../uview-ui/components/u-modal/u-modal";
	import{
		countCart
	} from '../../api/index/index.js'
import { showRuleSupplierInfoShow,qryConfByItemCode } from '@/api/user/user.js'
	import MarketingDiscount from '../../components/marketing/marketingDiscount.vue'
	export default {
    components: {UModal, URow, UCheckboxGroup, UIcon, UButton, USwitch, URadio, UPopup, UTabsSwiper,MarketingDiscount},
    data() {
		return {
			// 当前优惠信息
			currentDiscount:[],
			showDiscount:false,
		freightDecision: '0',
        // 审批人员列表
        approvalUserList:[],
        // 审批流模式选择
        approvalMode:0,
        // 审批流弹框设置
        approvalShow:false,
        orderCreateLoading:false,
        checkboxSelect:true,
        budgetChecked:false,
        showPopup:false,
        addBudgetVisible:false,
        errorImgUrl: errorImgUrl,
        //未关联商品是否有优惠价和服务费
        noneRefPreferential:false,
        // 关联商品是否有优惠价和服务费
        refPreferential:false,
        budgetModalShow:false,
        productModalShow:false,
        preOrderModalShow:false,
        relationBudgetProductsVisible:false,
        // 未关联商品弹显示，总
        noRelationBudgetProductVisible:false,
        commodityData:{},
        commodityVisible:false,
        addBudgetProductSelectedKeys:[],
        addBudgetProductSelectedData:[],
        // 是否显示服务费和优惠金额
        showPrice:false,
				maskState: 0, //支付方式面板显示状态
				desc: [], //备注
				payType: 1, //1微信 2支付宝
				addressData: {},
				addrData: {},
				orderData: {},
				orderList: [],
        // 预算配置信息
        orderBudget:{
          openBudget: false,
          budgetList: [],
          serviceFeeTotal:0
        },
        // 所有的预算
        budgetList:[],
        // 已添加的预算的key
        addBudgetSelectedKeys:[],
        // 已选择但未添加的预算
        addBudgetSelectedData:[],
        // 待添加预算
        addBudgetData:[],
        // 未添加的预算
        noRelationBudgetProductList:[],
        // 已关联的商品
        relationBudgetProducts:[],
				payWayIndexList: [],
        titleStyle:{
          width:'50%',
          fontSize:'28rpx',
          color:'#303133'
        },
        labelStyle:{
          fontSize:'28rpx',
          color:'#303133'
        },
        customStyle:{},
        // 已关联预算
        refBudget:'',
        // 未关联预算
        noneRefBudget:'',
        // 当前操作的预算
        optBudgetInfo:{},
        deleteBudget:{},
        total:'',
				payWayList: [{
          		id: 1,
          		name: '积分支付'
          	}],
        invoiceList:[{
				  name:'直接开票'
        },{
				  name:'不开发票'
        }],
        produceList: [{
          name: '已关联预算的商品列表'
        }],
        noneRefProduceList:[{
          name: '未关联预算的商品列表'
        }],
        activeColor:'#fa436a',
        activeItemStyle:{
          color:'#fa436a'
        },
        buttonStyle:{
          border:'#fa436a',
          color:'#fa436a',
          backgroundColor:'#fadee4',
          width:'40%',
          margin: '5px auto 5px auto',
        },
        addressCopyData: {
          consigneeName: '',
          mobile: '',
          areaId: '',
          areaName: '',
          addr: '',
          isDefault: false,
          email: ''
        },
        // 地区id
        areaIdList: [],
        province: [],
        indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/100))}px;`,
        valueArr: [0, 0, 0,0], //用于判断当前滑动的那一列
        areaId: '',
        current:0,
        orderIsAmountPass:false,
        approvalFlowId:"",
        operationTypeSer:"",
        firstOperationTypeSer:"",
        waitApprovalData:[],
        orderApprovalState:"0",
        selectedRows:[],
        supplierForms:{},
        swiperCurrent:0,
        isContainEmall:true,
        payMethodList:[],
        invoiceMethod:1,
        payMethodShow:'none',
        invoiceShow:'none',
        invoiceType:[],
        orderItemPayMethod:'',
				payWayMap: {},
				addrId: '',
				money: 0,
        invoiceTypeList:[],
				payWay: '',
        invoice:'',
        isInvoice: true,
        payWayIndex: 0,
        payMethodIndex:0,
        invoiceIndex:0,
        invoiceTypeIndex:0,
		realAmount: 0,
		paymentWay: 0,
		isActivity: false,
		activityInfo: {},
        supplierInfoShow: true,
		// 默认发票配置
		invoiceDefaultCashModel:false,
		showInvoice:true,
		// 自动匹配预算
		isAutoSelectBudget:false
		}
    },
    onShow(){
			this.getInvoiceType()
			this.getPreOrderInfo()
			// 发票列表
			this.getInvoiceList()
			// 加载预算配置
			this.getBudgetConf();
			// 获取供应商配置
			this.loadSupplierInfoShow();
    },
		onLoad(option) {
		  // 获得发票类型
      this.getInvoiceType()
			this.getPreOrderInfo()
      // 发票列表
      this.getInvoiceList()
      // 加载预算配置
      this.getBudgetConf();
      // 加载地区
      this.initLoadArea()
	  // 自动匹配预算配置
	  this.getAutoBudgetConf()
		},
    computed:{
      getOrderBudgetAmount:function (){
        return this.orderBudget.amount
      },
      getOrderDataAmount:function (){
        return this.orderData.amount
      }
    },
    watch:{
      getOrderBudgetAmount:{
        handler:function (){
          this.computeBudgetAmount()
        }
      },
      getOrderDataAmount:{
        handler:function (){
          this.computeBudgetAmount()
        }
      }
    },
		methods: {
			clickDiscount(item){
				// 多件折扣
				const temp = item.products.filter(p=>p.activityId&&p.price<p.originalPrice&&p.activityMap&&p.activityMap.type===1)
				if(temp.length>0) {
				  let actIdList = [...new Set(temp.map(p=>p.activityId))]
				  const result = []
				  actIdList.forEach(actId=>{
					const products = temp.filter(p=>p.activityId === actId)
					const activity = {...products[0].activityMap.data,...products[0].activityMap}
					result.push({activity:activity,products:products})
				  })
				  this.currentDiscount = result
				  console.log(this.currentDiscount)
				  this.showDiscount = true
				}
			},
      // 获取是否屏蔽供应商信息配置
      async loadSupplierInfoShow() {
        await showRuleSupplierInfoShow().then(res => {
          if (res.code === 0) {
            this.supplierInfoShow = !res.data;
          }
        })
      },
		returnIndex() {
				goback()
			},
			getCart() {
				countCart().then(res => {
					console.log(res)
					if (res > 0) {
						uni.setTabBarBadge({
							index: 2,
							text: res.toString()
						})
					} else {
						uni.removeTabBarBadge({
							index: 2
						})
					}
				})
			},
      // 修改审批流模式
      changeApprovalMode(e){
        // 指定人员
        // 或签审批
      },
      confirmApproval(){
        this.selectedRows = [];
        // 0.或签
        if (this.approvalMode === 0){
          this.selectedRows = this.approvalUserList
        } else {
          // 1.指定人员
          this.approvalUserList.forEach(user => {
            if(user.checked){
              this.selectedRows.push(user);
            }
          });
        }
        if(this.selectedRows.length <= 0){
          this.toast("请选择至少应该审批人！")
          return;
        }
        this.afterApprovalSubmit();
      },
      // 审批人勾选框
      checkApprovalUser(item){
        console.log(item)
        if (item.checked) {
          item.checked = false;
        } else {
          item.checked = true;
        }
      },
      // 计算预算关联金额
      computeBudgetAmount(){
        this.refBudget='已关联预算:￥'+this.$options.filters['twoBitMoney'](this.orderBudget.amount)
        if (this.orderBudget.useFreight>0){
          this.refBudget +='(含运费)'
        }
        this.noneRefBudget='未关联预算:￥'+this.$options.filters['twoBitMoney'](this.orderData.amount-this.orderBudget.amount)
        if (this.orderBudget.unUseFreight>0){
          this.noneRefBudget += '(含运费)'
        }
      },

      animationfinish({ detail: { current } }) {
        this.swiperCurrent = current;
        this.current = current;
      },
      onTabsChange(index){
        this.swiperCurrent = index
      },
      transition({ detail: { dx } }) {
        // this.$refs.tabs.setDx(dx);
      },
      // 未添加预算选择事件
      // checkboxChange(name,item){
      //   // item.checkboxSelect = !item.checkboxSelect
      // },
      // 全选未选择的预算
      switchChange(e){
        this.addBudgetData.forEach(item=>{
          item.checked = e
        })
        setTimeout(() => {
          this.$refs.testldb.emitEvent()
        }, 500)

      },
      // 查看预算关联商品
      getBudgetInfoDetail(record){
        // let that = this
        this.refPreferential = false
        this.optBudgetInfo = record
        seeBudgetInfoDetail({budgetInfoId: record.id}).then(res=>{
          if (res.code === 0){
            this.relationBudgetProducts = res.data
            this.relationBudgetProducts.forEach(item=>{
              item.key = item.id
              item.beforeRelationNum = item.relationNum
              var totalOtherRelationNum = 0
              this.orderBudget.budgetList.forEach(item1=>{
                if (item1.id != record.id){
                  item1.detailList.forEach(item2=>{
                    if (item.id === item2.id){
                      totalOtherRelationNum += Number(item2.relationNum)
                    }
                  })
                }
              })
              item.currUsableRelationNum = item.num - totalOtherRelationNum
            })
            if(this.orderBudget.serviceFeeTotal>0){
              this.refPreferential = true
            }
            this.relationBudgetProductsVisible = true
          }else {
            this.toast(res.message)
          }
        })
      },
      //新增预算关联商品
      addBudgetInfoDetail(record){
        this.optBudgetInfo = record
		// budgetInfoId: record.id,
        getCatalogNoRelationBudgetProducts({ catalogId: record.budgetCatalogId}).then(res=>{
          if(res.code === 0){
            res.data.forEach(item=>{
              item.key = item.id
              item.currBlanceNum = item.num - item.relationNum
              item.relationNum = item.currBlanceNum
            })
            this.commodityData = res.data
            this.commodityVisible = true
            this.addBudgetProductSelectedKeys = []
            this.addBudgetProductSelectedData = []
          }else {
            this.toast(res.message)
          }
        })
      },

      // 未关联商品数量框输入事件
      noneRefNumChange(index, value) {
        value = value.replace(/[^\d]/g, "");
        if (value > this.commodityData[index].currBlanceNum) {
          this.commodityData[index].relationNum = this.commodityData[index].currBlanceNum;
        }
      },
      // 已关联商品数量框输入事件
      refNumChange(index,value){
        value = parseInt(value.replace(/[^\d]/g,''))
        if (Number(value)>=Number(this.relationBudgetProducts[index].currUsableRelationNum)){
          this.relationBudgetProducts[index].relationNum = this.relationBudgetProducts[index].currUsableRelationNum
        }
        let amountTotal = 0;
        let numTotal = 0;
        let errmsg = "";
        this.optBudgetInfo.detailList.forEach((item1,index1)=>{
          if (index1 === index ){
            if(value>item1.currUsableRelationNum){
              errmsg = '已关联预算的商品数量超出商品总数量，请重新选择'
            }
            amountTotal += Number(item1.salePrice)*value
            numTotal+=value
          }else {
            numTotal+=Number(item1.relationNum)
            amountTotal+=Number(item1.relationSubtotal)
          }
        })
        //当前金额不能大于预算剩余金额
        if(errmsg){
          this.toast(errmsg)
          this.relationBudgetProducts[index].relationNum = this.relationBudgetProducts[index].beforeRelationNum
          return
        }
        //当前数量不能大于预算剩余数量
        if(this.optBudgetInfo.budgetControllerType.indexOf("02")!=-1){
          if(numTotal>this.optBudgetInfo.budgetNum){
            this.relationBudgetProducts[index].relationNum = this.relationBudgetProducts[index].num
            return
          }
        }
      },
      // 已关联商品加
      refAddPlus(index){
		  if(this.isAutoSelectBudget) return
        if (this.relationBudgetProducts[index].relationNum < this.relationBudgetProducts[index].currUsableRelationNum){
          this.relationBudgetProducts[index].relationNum++
        }
      },
      // 已关联商品减
      refReduce(index){
		  if(this.isAutoSelectBudget) return
        if (this.relationBudgetProducts[index].relationNum>0){
          this.relationBudgetProducts[index].relationNum--
        }
      },
      // 未关联商品数量加
      noneRefAddPlus(index) {
        if (this.commodityData[index].relationNum < this.commodityData[index].currBlanceNum){
          this.commodityData[index].relationNum++
        }
      },

      // 未关联商品数量减
      noneRefReduce(index) {
        if(this.commodityData[index].relationNum>0){
          this.commodityData[index].relationNum--
        }
      },

      // 已关联商品弹窗取消
      relationProductCancelBtnEvent(){
        this.relationBudgetProductsVisible = false
        this.relationBudgetProducts.forEach(item=>{
          item.key = item.id
          item.relationNum = item.beforeRelationNum
        })
      },
      //确认新增预算关联商品
      doAddBudgetInfoDetail(){
        let that = this;
        this.addBudgetProductSelectedData = []
        this.addBudgetProductSelectedKeys = []
        this.commodityData.forEach(item=>{
              that.addBudgetProductSelectedData.push(item);
              that.addBudgetProductSelectedKeys.push(item.key);
        })
        this.addBudgetProductSelectedData
        .filter((t)=> t.relationNum>0)
        .forEach(item=>{
          let existData = that.optBudgetInfo.detailList.filter(
              (t) => t.id === item.id
          );
          if (existData && existData.length > 0) {
            that.optBudgetInfo.detailList.filter(
                (t) => t.id === item.id
            )[0].relationNum = Number(existData[0].relationNum) + Number(item.relationNum)
          } else {
            that.optBudgetInfo.detailList.push(item)
          }
        })
        saveUserBudgetDetails(this.optBudgetInfo,1).then(res=>{
          if (res.code === 0){
            this.commodityVisible = false
            this.orderBudget = res.data.orderBudget
            this.orderBudget.budgetList.forEach(item=>{
              item.key = item.id;
            })
            res.data.noRelationBudgetProductList.forEach(item=>{
              item.key = item.id
              item.currBlanceNum = item.num - item.relationNum
              item.relationNum = item.currBlanceNum //修改默认未关联数量
            })
            this.noRelationBudgetProductList = res.data.noRelationBudgetProductList
          }else {
            this.toast(res.message)
          }
        })
      },
      // 是否删除预算弹窗
      deleteBudgetInfo(item){
        this.deleteBudget = item
        this.budgetModalShow = true
      },
      // 忽视预算不足，直接下单
      preOrderModalConfirm(){
        this.productModalShow = false
        this.submitOrder(false)
      },
      // 确认更改关联商品数量
      productModalConfirm(){
        let that = this
        this.optBudgetInfo.detailList.forEach(item =>{
          let data =  this.relationBudgetProducts.filter((t) => t.id === item.id)[0]
          if (!isEmpty(data)){
            item.relationNum = parseInt(data.relationNum)
          }
        })
        this.optBudgetInfo.detailList = that.optBudgetInfo.detailList.filter((t) => t.relationNum > 0)
        saveUserBudgetDetails(this.optBudgetInfo,2).then(res=>{
          if (res.code === 0){
            res.data.orderBudget.budgetList.forEach((item,index)=>{
              item.key = index
            })
            this.orderBudget = res.data.orderBudget
            this.noRelationBudgetProductList = res.data.noRelationBudgetProductList
            this.noRelationBudgetProductList.forEach(item=>{
              item.key = item.id
              item.currBlanceNum = item.num - item.relationNum
              item.relationNum = item.currBlanceNum
            })
            this.relationBudgetProductsVisible = false
          }else {
            this.toast(res.message)
          }
        })
      },
      // 确认删除预算
      budgetModalConfirm(){
        removeUserBudgetInfo({id:this.deleteBudget.id}).then(res=>{
          if (res.code === 0){
            res.data.orderBudget.budgetList.forEach((item,index)=>{
              item.key = index
            })
            this.orderBudget = res.data.orderBudget
            this.noRelationBudgetProductList = res.data.noRelationBudgetProductList
            this.noRelationBudgetProductList.forEach(item=>{
              item.key = item.id;
              item.currBlanceNum = item.num - item.relationNum;
              item.relationNum = item.currBlanceNum;
            });
          } else {
            this.toast(res.message)
          }
        })
      },
      checkboxChange(e){
      },
      // 已选择的预算
      checkboxGroupChange(e){
        this.addBudgetSelectedData = e
        this.addBudgetSelectedKeys=[]
        e.forEach(item=>{
          this.addBudgetSelectedKeys.push(item.key)
        })
      },
      getTotalPrice(record){
        let totalSalePrice = parseFloat(Number(record.num*record.salePrice).toFixed( 2 ));
        let totalServiceFee = parseFloat(Number(record.num*record.serviceFee).toFixed( 2 ));
        let totalPreferentialFee =parseFloat( Number(record.num*record.preferentialFee).toFixed( 2 )) ;
        let total = this.$options.filters['twoBitMoney'](totalSalePrice+totalServiceFee+record.showFreight-totalPreferentialFee);
        return total

      },
	  // 自动匹配预算配置
	  getAutoBudgetConf(){
		  const deptInfo = uni.getStorageSync('deptinfo')[0]
		  qryConfByItemCode({
			  code:'orderBudgetControl_isAutoSelectBudget',
			  tenant_id: deptInfo.tenantId,
			  dept_code: deptInfo.deptCode
		  }).then(res=>{
			  if(res.code===0){
				  this.isAutoSelectBudget = res.data.val == '1'
			  }
		  })
	  },
      // 预算配置
      getBudgetConf(){
        this.noneRefPreferential = false
        getBudgetConf().then(res=>{
          if (res.code === 0){
            res.data.orderBudget.budgetList.forEach(function (item, index) {
              item.key = index;
            })
            this.orderBudget = res.data.orderBudget
            if (this.orderBudget.serviceFeeTotal>0){
              this.noneRefPreferential = true
            }
            this.noRelationBudgetProductList = res.data.noRelationBudgetProductList
            this.noRelationBudgetProductList.forEach(function (item, index) {
              item.key = item.id
              item.currBlanceNum = item.num - item.relationNum
              item.relationNum = item.currBlanceNum
            })
          }
        })
      },
      // 选择对应的预算到已选择预算里
      budgetSelectedConfirm(){
        if (this.addBudgetSelectedData.length===0){
          this.toast('至少选择一条预算')
          return
        }
        var budgetList = this.orderBudget.budgetList
        this.addBudgetSelectedData.forEach(item=>{
          var budgetInfo = {};
          budgetInfo.id = item.id;
          budgetInfo.budgetId = item.id;
          budgetInfo.budgetCode = item.code;
          budgetInfo.budgetName = item.name;
          budgetInfo.budgetBalance = item.amount - item.usedAmount - item.occupyAmount;
          budgetInfo.budgetNum = item.num - item.usedNum - item.occupyNum;
          budgetInfo.amount = 0;
          budgetInfo.num = 0;
          budgetInfo.budgetCatalogId = item.catalogId;
          budgetInfo.budgetCatalogName = item.catalogName;
          budgetInfo.costControllerType = item.costControllerType;
          budgetInfo.budgetControllerType = item.budgetControllerType;
          budgetInfo.isInfiniteAmount = item.isInfiniteAmount;
          budgetInfo.isInfiniteNum = item.isInfiniteNum;
          budgetInfo.infiniteAmount = item.isInfiniteAmount;
          budgetInfo.infiniteNum = item.isInfiniteNum;
          if (budgetList.filter((t) => t.id === budgetInfo.id).length === 0) {
            //避免重复添加
            budgetList.push(budgetInfo);
          }
        })
        budgetList.forEach(item=>{
          item.infiniteAmount = item.isInfiniteAmount;
          item.infiniteNum = item.isInfiniteNum;
        })
        //添加用户预算列表数据
        addBudgetList(budgetList).then(res=>{
          if (res.code === 0){
            this.addBudgetVisible = false
            this.orderBudget = res.data
            this.orderBudget.budgetList.forEach(item=>{
              item.key = item.id
            })
            this.total = '总金额: ￥'+ this.$options.filters['money'](this.orderData.amount)
          }else {
            this.toast(res.message)
          }
        })
      },
      budgetSelectedCancel(){
        this.budgetChecked = this.budgetChecked? !this.budgetChecked:this.budgetChecked
            this.addBudgetVisible = false
      },
      onSwiperChange(item){
        // this.showButton = !this.showButton
      },

      //选择支付方式
      doPayMethodSelect(item){
        this.orderItem = item
        this.payMethodList = item.payways
        this.payMethodShow = 'show'
      },
      // 获得发票类型
      getInvoiceType(){
        getInvoiceType().then(res=>{
          if(res.code === 0){
            this.invoiceType = res.data
          }
        })
      },
      // 预算列表
      getBudgetData(){
        getBudgetList({page:1,limit:30,sort: 'create_time', keyword: '' }).then(res=>{
          if (res.code === 0){
            this.addBudgetSelectedKeys = []
            this.addBudgetSelectedData = []
            this.addBudgetVisible = true
            if (this.orderBudget.budgetList && this.orderBudget.budgetList.length>0){
              let waitSelectedBudgets = []
              res.data.records.forEach(item=>{
                item.key = item.id
                var existBudgets = this.orderBudget.budgetList.filter(
                    (t) => t.budgetId === item.id
                );
                if (existBudgets.length < 1) {
                  waitSelectedBudgets.push(item);
                }
              })
              this.addBudgetData = waitSelectedBudgets
            }else{
              this.addBudgetData = res.data.records;
            }
            this.addBudgetData.forEach(item=>{
              item.key = item.id;
              this.$set(item,'checked',false)
              this.$set(item,'disabled',false)
            })
          }else {
            this.toast(res.message)
          }
        })
      },
      // 发票列表
      getInvoiceList(){
        doLoadingInvoiceList({ page: 1, limit: 30 }).then(res=>{
		  if(res.code === 0){
			  this.invoiceTypeList = res.data.records
			  // 默认发票
			  // this.invoiceTypeList.forEach((item,index)=>{
			  //   if (item.isDefault){
			  //     this.invoiceTypeIndex = index
			  //     this.invoice = item.title
			  //   }
			  // })
			  if (this.invoiceTypeList.length>0){
				this.invoice = this.invoiceTypeList[0]
			  }else {
				this.invoice = { title : '暂无可选发票'}
			  }
		  }
		  // 广州银行发票配置 是否直接使用管理员发票开票
		  this.loadInvoiceConf()
        }).catch(()=>{
			// 广州银行发票配置 是否直接使用管理员发票开票
			this.loadInvoiceConf()
		})
      },
	  // 加载发票配置
	  loadInvoiceConf(){
		  getInvoiceConf({
			deptId: uni.getStorageSync('deptinfo')[0].deptId,
			tenantId: uni.getStorageSync('deptinfo')[0].tenantId,
          }).then(res=>{
			  console.log(res)
			  if(res.code===0){
				if (res.data.length > 0) {
				    const data = res.data[0]
				    this.invoiceDefaultCashModel = data.invoiceDefaultCashModel
				    if (this.invoiceDefaultCashModel) {
						this.showInvoice = false
						this.getCurAdminInvoice()
					}
		    	}
			  }else{
				  this.$util.msg(res.message)
			  }
		  }).catch((e)=>{
			  console.log(e)
		  })
	  },
	  getCurAdminInvoice(){
		  getAdminInvoice().then(res=>{
			  if(res.code === 0){
				  const invoiceList = res.data.records
				  if(invoiceList.length>0){
					  this.invoice = invoiceList[0]
					  console.log(this.invoice)
				  }else{
					  this.$util.msg('当前没有配置发票，请联系管理员配置统一发票')
				  }
			  }else{
				  this.$util.msg(res.message)
			  }
		  }).catch((e)=>{
			  console.log(e)
		  })
	  },
			// 加载收货地址列表
			loadAddrList() {
				const params = {
					page: 1,
					limit: 10
				}
				getAddressList(params).then(res => {
					let flag = false
					if (res.code === 0) {
						if (res.data !== null) {
							this.addrData = JSON.parse(JSON.stringify(res.data));
							console.log('------------')
							if(!this.addrData.records.length) {
								this.addressData = {}
							}else {
								this.addrData.records.forEach(addr => {
									if (addr.isDefault && !this.addressData.id) {
										this.addressData = addr;
										flag = true;
									}else if (this.addressData) {
										console.log(addr.id, this.addressData.id)
										if(addr.id === this.addressData.id) {
											flag = true;
											this.addressData = addr;
										}
									}
								})
							}
							if(!flag) {
								this.addressData = {};
							}
              this.calcFreight()
						}
					} else {
						this.toast(res.message)
					}
				})
			},
			//加载预购单信息
			getPreOrderInfo() {
				getPreOrder().then(res => {
					this.orderData = res;
					this.orderData.supplierDiscountSum = 0
					console.log(this.orderData)
          this.orderList = this.orderData.items;
					this.orderList.forEach(item=>{
            if (item.confService) {
              this.showPrice = true;
            }
            // 计算优惠金额
            let supplierDiscountSum = 0;
            item.products.forEach(product => {
				if (product.goodsSourceType !== '0' && this.isContainEmall){
				  this.isContainEmall = false
				}
              supplierDiscountSum = supplierDiscountSum.addFloat((product.originalPrice.subtractFloat(product.salePrice)).multipleFloat(product.num))
            });
			item.supplierDiscountSum = supplierDiscountSum
			this.orderData.supplierDiscountSum = this.orderData.supplierDiscountSum.addFloat(item.supplierDiscountSum)
            this.payWayIndexList.push(0)
            this.desc.push('')
            item.payMethod = item.payways[0]
          })
          this.invoiceList = [{
            name:'直接开票'
          }]
          if(this.isContainEmall){
            this.invoiceList.push({name:'不开发票'})
          }
					this.loadAddrList()
          this.calcMoney()
				})
			},

			//计算运费
			calcFreight() {
				let supplierMap = {}
				this.orderList.forEach(order => {
					const value = {
						remark: order.remark,
						reason: order.reason,
						paywayId: order.payMethod.id
					}
					supplierMap[order.id] = value
				})
				const params = {
					supplierFormMap: supplierMap,
					receiverAddressId: this.addressData.id || uni.getStorageSync('addrId')
				}
				// 计算运费接口
				getOrderFeeInfo(params).then(res => {
					if (res.code === 0) {
						// 新增 - 是由谁控制运费
						this.freightDecision = res.data.freightDecision;
						this.orderData.freight = res.data.freight
						this.orderList.amount = res.data.amount
						this.orderData.amount = res.data.amount
						console.log(this.orderList,'am')
            this.orderList.forEach(item=>{
              var freightItem = res.data.items.filter((t)=>t.id == item.id)[0]
              item.freight = freightItem.freight
            })
					}
				})
			},
			changePayWay(item, index) {
				this.payWayIndex = index;
			},
      changeInvoice(item,index){
        console.log(item,index)
        this.invoiceIndex = index
        if (index === 1){
          this.invoice = {title:'不开发票'}
          this.isInvoice =false
        }else {
			if(this.invoiceTypeList.length>0)
				this.invoice = this.invoiceTypeList[0]
			else {
				this.invoice = { title : '暂无可选发票'}
          }
        }
      },
      // 更改支付类型
      changeInvoiceType(item,index){
        this.invoiceTypeIndex = index
        this.invoice = item
      },
      // 更改支付方式
      changePayMethod(item,index){
        this.orderItemPayMethod = item
        this.payMethodIndex = index
      },
      confirmPayMethod(){
        if (this.orderItemPayMethod!=''){
          this.orderItem.payMethod = this.orderItemPayMethod
          this.calcFreight()
        }
        this.payMethodShow = 'none'
      },
			confirmRule() {
				this.calcMoney()
				this.toggleMask('close')
			},
      // 初始化地区
      initLoadArea() {
        loadAddr().then(res => {
          if (res.code === 0) {
            this.province = res.data;
            this.loadCity(this.province[0].id)
          } else {
            this.toast(res.message)
          }
        })
      },
      loadCity(parentId) {
        const params = {
          parentId: parentId
        }
        loadChildAddr(params).then(res => {
          if (res.code === 0) {
            this.city = res.data;
            if (!this.province[this.valueArr[0]].children||this.province[this.valueArr[0]].children.length===0) {
              this.$set(this.province[this.valueArr[0]], 'children', [])
              res.data.forEach(item => {
                this.province[this.valueArr[0]].children.push(item)
              })
              this.loadArea(this.province[this.valueArr[0]].children[this.valueArr[1]].id,1)
              //this.loadArea(this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].id,2)
            }
          } else {
            this.toast(res.message)
          }
        })
      },
      loadArea(parentId,level) {
        const params = {
          parentId: parentId
        }
        loadChildAddr(params).then(res => {
          if (res.code === 0) {
            this.area = res.data;
            if(level===1)
            {
              if (!this.province[this.valueArr[0]].children[this.valueArr[1]].children||this.province[this.valueArr[0]].children[this.valueArr[1]].children.length===0) {
                this.$set(this.province[this.valueArr[0]].children[this.valueArr[1]], 'children', [])
                res.data.forEach(item => {
                  this.province[this.valueArr[0]].children[this.valueArr[1]].children.push(item)
                })
              }
              this.loadArea(this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].id,2);
            }
            else if(level===2)
            {
              if (!this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].children||this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].children.length===0) {
                this.$set(this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]], 'children', [])
                res.data.forEach(item => {
                  this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].children.push(item)
                })
              }
            }
          } else {
            this.toast(res.message)
          }
        })
      },
      // 发票取消
      cancelInvoice(){
        // if (this.supplierInfoShow==false){
        //   this.invoiceShow = 'none'
        // }else{
        if (this.isInvoice==true) {
          let data = this.addressCopyData;
          if (!data.consigneeName) {
            this.$api.msg('请填写收货人姓名');
            return;
          }
          if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(data.mobile)) {
            this.$api.msg('请输入正确的手机号码');
            return;
          }
          if (!data.areaName) {
            this.$api.msg('请选择收货地址');
            return;
          }
          if (!data.addr) {
            this.$api.msg('请填写详细地址');
            return;
          }
          this.invoiceShow = 'none'
        }else{
          this.invoiceShow = 'none'
        }
        // }
      },
      toggleTab() {
        this.$refs.popup.open();
      },
      cancel() {
        this.$refs.popup.close();
      },
      confirmAddress() {
        this.$refs.popup.close();
        let children=this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].children
        if(children && children.length>0){
          this.addressCopyData.areaName = this.province[this.valueArr[0]].name + '/' + this.province[this.valueArr[0]].children[
                  this.valueArr[1]].name +
              '/' +
              this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].name+
              '/' +children[this.valueArr[3]].name

          this.areaId = children[this.valueArr[3]].id;
          this.areaIdList=[
            this.province[this.valueArr[0]].id,
            this.province[this.valueArr[0]].children[this.valueArr[1]].id,
            this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].id
          ]
        }
        else{
          this.addressCopyData.areaName = this.province[this.valueArr[0]].name + '/' + this.province[this.valueArr[0]].children[
                  this.valueArr[1]].name +
              '/' +
              this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].name
          this.areaIdList=[
                this.province[this.valueArr[0]].id,
                this.province[this.valueArr[0]].children[this.valueArr[1]].id,
                this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].id
          ]
          this.areaId = this.province[this.valueArr[0]].children[this.valueArr[1]].children[this.valueArr[2]].id;
        }
      },
      sameConsignee(){
        let that=this
        this.addrData.records.forEach(function(item, index) {
          if (item.isDefault === true) {
            that.addressCopyData.consigneeName=item.consigneeName
            that.addressCopyData.mobile=item.mobile
            that.addressCopyData.areaName=item.areaName
            that.addressCopyData.addr=item.addr
            let data={
              areaId:item.areaId
            }
            loadChildAllAddr(data).then(response => {
                  if (response.code == 0) {
                    let areaIdss=[]
                    for (let i = 0; i < response.data.length; i++) {
                      areaIdss.push(response.data[i].id)
                    }
                    that.areaIdList=areaIdss

                  } else {
                    that.toast(response.data.message)
                    // this.$message.error(response.data.message);
                  }
                });
          }
        });
      },
      bindChange(e) {
        const val = e.detail.value;
        if (this.valueArr[0] !== val[0]) {
          this.loadCity(this.province[val[0]].id)
        } else if (this.valueArr[1] !== val[1]) {
          this.loadArea(this.province[val[0]].children[val[1]].id,1)
        }
        else if (this.valueArr[2] !== val[2]) {
          this.loadArea(this.province[val[0]].children[val[1]].children[val[2]].id,2)
        }
        this.valueArr = val
        console.log(this.valueArr)
      },
			calcMoney() {
					this.money = this.orderData.total;
					this.realAmount = '￥ ' + this.money
					this.paymentWay = 4;

			},
			toast(msg) {
				uni.showToast({
					title: msg,
					duration: 1200,
					mask: false,
					icon: 'none'
				});
			},
      // 下单前的校验
			beforeSubmitOrder() {
        if (this.orderCreateLoading){
          return;
        }
        this.orderCreateLoading = true;
        // 下单前对发票的校验
        if (this.invoiceIndex===1){
          this.invoiceMethod = 2
        }
			if (this.invoice.id===undefined&&this.invoiceIndex===0){
				if(this.invoiceDefaultCashModel&&!this.showInvoice){
					this.$util.msg('当前没有配置发票，请联系管理员配置统一发票')
					  this.orderCreateLoading = false;
					return
				}else{
				  uni.showToast({
					title: '暂无可选发票，请在个人中心中添加！',
					duration: 3000,
					icon:'none'
				  });
				  this.orderCreateLoading = false;
				  return
			  }
			}

        // 下单前对预算的校验
        if (this.orderBudget.openBudget){
          if (this.orderBudget.budgetMust){
            if (this.orderBudget.budgetList.length === 0){
              this.toast('请选择预算')
              this.orderCreateLoading = false;
              return false
            }
            if (this.noRelationBudgetProductList.length > 0){
              this.toast('请给未关联预算的商品关联预算')
              this.orderCreateLoading = false;
              return false
            }
          }
          var budgetValidMsg = ''
          if (this.orderBudget.budgetList && this.orderBudget.budgetList.length > 0){
            this.orderBudget.budgetList.forEach(item=>{
              if (item.budgetControllerType.indexOf("01") !== -1 && item.amount > item.budgetBalance && !item.infiniteAmount){
                budgetValidMsg = budgetValidMsg + "预算" + item.budgetName + "使用金额不能大于可用金额"
              }
              if (item.budgetControllerType.indexOf("02") !== -1 && item.num > item.budgetNum  && !item.infiniteNum){
                budgetValidMsg = budgetValidMsg + "预算" + item.budgetName + "使用数量不能大于可用数量"
              }
            })
          }
          if (budgetValidMsg && this.orderBudget.overBudgetControl === 'noAllowPurchase'){
            this.toast(budgetValidMsg)
            this.orderCreateLoading = false;
            return false
          }
        }

        if (budgetValidMsg && this.orderBudget.overBudgetControl === 'allowPurchase'){
          this.productModalShow = true
        }else {
          this.submitOrder(false)
        }


			},
			async getIsBlack() {
				await isBlackPermissionV2({ apiUrl: '/api/orders/create'}).then(res => {
					if(res.code == 0) {
						debugger
						this.isBlack = res.data
						
						}
					
				})
			},
      // 正式下单
      async submitOrder(isAmountPass){
		  await this.getIsBlack()
		  uni.hideLoading()
		  	if(this.isBlack =='inBlackList') {
		  		this.orderCreateLoading = false;
		  		uni.showModal({
		  			title: '系统提醒',
		  			content: '很抱歉，您已被限制无法使用该功能。如需解除，您可通过发起申请，待平台方审批通过后方可恢复权限。',
		  			confirmText: '确定',
		  			showCancel: false,//没有取消按钮的弹框
		  			success: (suc) => {
		  				
		  			}
		  		})
		  		return false
		  }
        this.orderIsAmountPass = isAmountPass;
        this.orderCreateLoading = true;
        this.supplierForms = {};
        this.orderData.items.forEach((item, index) => {
          var supplierFormData = {};
          supplierFormData.remark = item.remark
          supplierFormData.reason = item.reason
          if (item.payways && item.payways.length > 0) {
            supplierFormData.paywayId = item.payMethod.id; //默认选第一个
          }
          this.supplierForms[item.id] = supplierFormData;
        });
        const params = {
          receiverAddressId: this.addressData.id,
          invoiceMethod: this.invoiceMethod,
          invoiceId: this.invoice.id,
          remark: '',
          supplierFormMap: this.supplierForms,
          fileIds: [],
          isAmountPass:this.orderIsAmountPass,
          invoiceName: this.addressCopyData.consigneeName,
          invoicePhone: this.addressCopyData.mobile,
          invoiceProvince: this.areaIdList[0],
          invoiceCity: this.areaIdList[1],
          invoiceCounty: this.areaIdList[2],
          invoiceAddress: this.addressCopyData.addr,
        }
        console.log('params',params);
        getApprovalFlowByUser(params).then(response=>{
          if (response.code == 0) {
            let data = response.data;

            var userData=data.userList;
            this.approvalFlowId=data.approvalFlowId;
            this.operationTypeSer=data.operationTypeSer;
            this.firstOperationTypeSer=data.firstOperationTypeSer;
            this.sumRes=data.sumRes;
            if (data.userList && data.userList.length > 0){
              userData = data.userList;
              this.approvalUserList = userData
              this.approvalShow = true;
              this.approvalMode = 0;
              this.orderCreateLoading = false;
              return;
            }
            // if(userData&&userData.length>0){
            //   this.waitApprovalData=userData;
            //   this.orderApprovalState='0';
            //   this.selectedRows = userData;
            // }
            this.selectedRows = [];
            this.afterApprovalSubmit()
          }else {
			  this.toast(response.message)
			  this.orderCreateLoading = false;
		  }
        }).catch(err => {
			this.toast(err)
			this.orderCreateLoading = false;
		})
      },
      // 选择审批流接收人后进行下单
      afterApprovalSubmit(){
        this.orderCreateLoading = true;
        var param = {
          receiverAddressId: this.addressData.id,
          invoiceMethod: this.invoiceMethod,
          invoiceId: this.invoice.id,
          remark: '',
          supplierFormMap: this.supplierForms,
          fileIds: [],
          isAmountPass:this.orderIsAmountPass,
          sumRes: this.sumRes,
          operationTypeSer:  this.operationTypeSer,
          firstOperationTypeSer:this.firstOperationTypeSer,
          approvalFlowId:this.approvalFlowId,
          selectedUser:this.selectedRows,
          invoiceName: this.addressCopyData.consigneeName,
          invoicePhone: this.addressCopyData.mobile,
          invoiceProvince: this.areaIdList[0],
          invoiceCity: this.areaIdList[1],
          invoiceCounty: this.areaIdList[2],
          invoiceAddress: this.addressCopyData.addr,
		  freightDecision: this.freightDecision
        }
        createOrder(param).then(res => {
          if (res&&res.code === 0) {
						this.getCart()
            this.$util.msg('下单成功！')
            uni.redirectTo({
              url: '/pages/order/order?state=0'
            })
          } else {
			  if(res) {
				  this.$util.msg(res.message)
			  }
            this.orderCreateLoading = false;
            
          }
            this.orderCreateLoading = false;
        })
      },
			//显示优惠券面板
			toggleMask(type) {
				let timer = type === 'show' ? 10 : 300;
				let state = type === 'show' ? 1 : 0;
				this.maskState = 2;
				setTimeout(() => {
					this.maskState = state;
				}, timer)
			},
			numberChange(data) {
				this.number = data.number;
			},
			changePayType(type) {
				this.payType = type;
			},
			submit() {
				uni.redirectTo({
					url: '/pages/money/pay'
				})
			},
			stopPrevent() {},
		}
	}
</script>

<style lang="scss">
/deep/ .input-view{
  margin: 18px auto;
}
	page {
		background: $page-color-base;
	}
.row {
  display: flex;
  align-items: center;
  position: relative;
  padding: 0 30upx;
  height: 110upx;
  background: #fff;

  .tit {
    flex-shrink: 0;
    width: 140upx;
    font-size: 30upx;
    color: $font-color-dark;
  }

  .delete {
    flex-shrink: 0;
    width: 120upx;
    font-size: 30upx;
    color: #fa436a;
  }

  .input {
    flex: 1;
    font-size: 30upx;
    color: $font-color-dark;
  }

  .icon-shouhuodizhi {
    font-size: 36upx;
    color: $font-color-light;
  }
}
.popup {
  height: fit-content;
  width: 100%;
  background: #fff;
}
.add-btn {
  flex: 1;
  height: 80upx;
  line-height: 80upx;
  margin: 60upx auto;
  font-size: $font-lg;
  color: #fff;
  // background-color: $my-newh5-color;
  border-radius: 10upx;
  // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  
  &:last-child{
	  margin-left: 30rpx;
  }
}
.picker-btn {
  display: flex;
  height: 100upx;
  width: 100%;
  line-height: 100upx;
  background: #fff;
  font-size: 34upx;
  z-index: 1;
  border-bottom: 1rpx solid #ccc;

  .left {
    flex: 1;
    color: #0076FF;
    padding-left: 40upx;
    box-sizing: border-box;
  }

  .right {
    flex: 1;
    text-align: right;
    padding-right: 40upx;
    color: #FE4533;
    box-sizing: border-box;
  }
}
picker-view {
  width: 100%;
  height: 500rpx;
  display: relative;
}
  .check-box{
    background-color: #dd524d;
  }
  .approval-container{
    padding-top: 12upx;
    .title{
      text-align: center;
      font-weight: bolder;
      padding-top: 20upx;
      padding-bottom: 20upx;
      border-bottom: 1px solid #ddd;
      font-size: 36upx;
    }
    .mode-choice-container{
      padding-top: 12upx;
      padding-bottom: 12upx;
      text-align: right;
    }
    .list-container{
      height: 300px;
      overflow: scroll;
      .u-form-item{
        padding: 0px;
      }
    }
    .sure-button{
      margin-top: 12upx;
    }
    .select-container{
      padding-top: 12upx;
      padding-bottom: 12upx;
      padding-left: 20upx;
      border-bottom: 1px solid #ddd;
      .font-title{
        color: rgb(160, 160, 160);
      }
      .font-name{
        font-size: 32upx;
      }
      .font-job{
        color: #fa436a;
      }
      .font-dept-name{
        color: rgb(75, 75, 75);
      }
    }
  }
  .checkbox {
    position: absolute;
    left: 20upx;
    top: 50upx;
    z-index: 8;
    font-size: 44upx;
    line-height: 1;
    padding: 4upx;
    color: $font-color-disabled;
    background: #fff;
    border-radius: 50px;
    &.checked{
      color: $uni-color-primary;
    }
  }
  .budget-title{
    font-size: 15px;
    font-weight: bold;
    text-align: center;
    height: 80rpx;
    width: 100%;
	padding-top: 12px;
    white-space: nowrap;
    position: relative;
  }
  .bottom {
    display: flex;
    margin-top: 15rpx;
    padding: 0 10rpx;
    justify-content: space-between;
    align-items: center;
    .btn {
      line-height: 52rpx;
      width: 160rpx;
      border-radius: 26rpx;
      border: 2rpx solid $u-border-color;
      font-size: 26rpx;
      text-align: center;
      color: $u-type-info-dark;
    }
    .evaluate {
      color: $u-type-warning-dark;
      border-color: $u-type-warning-dark;
    }
  }

  .wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
  }
  .product-box {
    display: flex;
    align-items: center;

    .product {
      font-size: 30upx;
      color: $font-color-dark;
    }
  }
  .u-box {
    font-size: 28upx;
    color: $font-color-light;
    .name {
      margin-right: 10upx;
    }
  }

  .list {
    display: flex;
    align-items: center;
    padding: 20upx 52upx;
    background: #fff;
    position: relative;
  }



  .uni-num-box {
    display: flex;
    //margin-right: 3px;
    justify-content: flex-end;
    .add,
    .subtract {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 60rpx;
      height: 60rpx;
      color: #333;
      font-size: 40rpx;
      border: 1rpx solid #e5e5e5;
      background-color: #f8f8f8;
      border-top-left-radius: 10rpx;
      border-bottom-left-radius: 10rpx;
      &.disabled {
        color: $font-color-disabled;
      }
    }

    .count {
      display: flex;
      align-items: center;
      width: 100rpx;
      height: 60rpx;
      line-height: 50rpx;
      font-size: 14px;
      text-align: center;
      border-top: 1rpx solid #e5e5e5;
      border-bottom: 1rpx solid #e5e5e5;
      background-color: #fff;
    }
  }
  .swiper-box {
    flex: 1;
    height: 350px !important;
    background-color: #f5f5f5;
    .swiper-item{
      padding: 20rpx;
      overflow-y:auto;

    }
  }
  .order {
    background-color: #ffffff;
    border-radius: 20rpx;
    box-sizing: border-box;
    padding: 20rpx;
    margin-bottom: 20rpx;
    font-size: 28rpx;
    .item {
      display: flex;
      margin: 20rpx 0 0;
      .left {
        margin-right: 20rpx;
        image {
          width: 160rpx;
          height: 160rpx;
          border-radius: 10rpx;
        }
      }
      .title {
        font-size: 28rpx;
        line-height: 50rpx;
      }
      .right {
        margin-left: auto;
        padding-top: 20rpx;
        text-align: right;
        .decimal {
          font-size: 24rpx;
          margin-top: 4rpx;
        }
        .price{
          color: $base-color;
        }
        .number {
          color: $u-tips-color;
          font-size: 24rpx;
        }
      }
    }
    .totalPrice {
      display: flex;
      justify-content: space-between;
      .combine{
        margin: auto 0 auto;
        .price{
          color: #fa436a;
          display: inline;
        }
      }
    }
    .total {
      color: $font-color-light;
      justify-content: flex-end;
      //margin-top: 10rpx;
      display: flex;
      font-size: 24rpx;
      .num{
        color: $font-color-dark;
      }
      .total-price {
        font-size: 32rpx;
        color: $uni-color-primary;
      }
    }
  }
  .container {
		background: $page-color-base;
		padding-bottom: 106upx;
		padding-left: 16rpx;
		padding-right: 16rpx;
	}

	.address-section {
		// margin-top: 16rpx;
		padding: 30upx 0;
		background: #fff;
		position: relative;
		border-radius: 10px 10px 0 0;

		.order-content {
			display: flex;
			align-items: center;
		}

		.icon-shouhuodizhi {
			flex-shrink: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 90upx;
			color: #888;
			font-size: 44upx;
		}

		.cen {
			display: flex;
			flex-direction: column;
			flex: 1;
			font-size: 28upx;
			color: $font-color-dark;
		}

		.name {
			font-size: 34upx;
			margin-right: 24upx;
		}

		.address {
			margin-top: 16upx;
			margin-right: 20upx;
			color: $font-color-light;
		}

		.icon-you {
			font-size: 32upx;
			color: $font-color-light;
			margin-right: 30upx;
		}

		.a-bg {
			position: absolute;
			left: 0;
			bottom: 0;
			display: block;
			width: 100%;
			height: 5upx;
		}
	}
  .a-bg {
    position: relative;
    margin-top: 20rpx;
    display: block;
    width: 100%;
    height: 5upx;
  }
	.goods-section {
		margin-top: 16upx;
		background: #fff;
		// padding-bottom: 1px;
		// padding: 16upx;
		padding-bottom: 10rpx;
		border-radius: 10px;

		.sum {
			text-align: right;
			padding: 10upx 30upx 10upx 0upx;
			background: #fff;
		}

		.sum-num {
			font-size: 26upx;
			color: $font-color-light;
			margin-right: 10upx;
		}

		.sum-total-tit {
			font-size: 24upx;
			color: $font-color-dark;
		}

		.sum-total-price {
			font-size: 28upx;
			color: $base-color;
		}

		.g-header {
			display: flex;
			align-items: center;
			height: 84upx;
			padding: 0 30upx;
			position: relative;
		}

		.logo {
			display: block;
			width: 50upx;
			height: 50upx;
			border-radius: 100px;
		}

		.name {
			font-size: 30upx;
			color: $font-color-dark;
			margin-left: 10upx;
		}

		.order {
			font-size: 26upx;
			color: $font-color-base;
			margin-left: 24upx;
      position: absolute;
      right: 0;
      top: 0;
		}

		.g-item {
			display: flex;
			margin: 20upx 30upx;

			image {
				flex-shrink: 0;
				display: block;
				width: 140upx;
				height: 140upx;
				border-radius: 4upx;
			}

			.right {
				flex: 1;
				padding-left: 24upx;
				overflow: hidden;
			}

			.title {
				font-size: 30upx;
				color: $font-color-dark;
			}

			.spec {
				font-size: 26upx;
				color: $font-color-light;
			}

			.price-box {
				display: flex;
				align-items: center;
				font-size: 32upx;
				color: $font-color-dark;
				padding-top: 10upx;

				.price {
					color: $base-color;
					// margin-bottom: 4upx;
				}

				.number {
					font-size: 26upx;
					margin-left: 20upx;
				}
			}

			.step-box {
				position: relative;
			}
		}
	}

	.yt-list {
		margin-top: 16upx;
		background: #fff;
	}

	.yt-list-cell {
		display: flex;
		align-items: center;
		padding: 10upx 30upx 10upx 200upx;
		line-height: 70upx;
		position: relative;

		&.cell-hover {
			background: #fafafa;
		}

		&.b-b:after {
			left: 30upx;
		}

		.cell-icon {
			height: 32upx;
			width: 32upx;
			font-size: 22upx;
			color: #fff;
			text-align: center;
			line-height: 32upx;
			background: #f85e52;
			border-radius: 4upx;
			margin-right: 12upx;

			&.hb {
				background: #ffaa0e;
			}

			&.lpk {
				background: #3ab54a;
			}

		}

		.cell-more {
			align-self: center;
			font-size: 24upx;
			color: $font-color-light;
			margin-left: 8upx;
			margin-right: -10upx;
		}

		.cell-tit {
			flex: 1;
			font-size: 26upx;
			color: $font-color-dark;
			margin-right: 10upx;
		}

		.cell-tip {
			font-size: 26upx;
			color: $font-color-dark;

			&.disabled {
				color: $font-color-light;
			}

			&.active {
				color: $base-color;
			}

			&.red {
				color: $base-color;
			}
		}

		&.desc-cell {
			.cell-tit {
				max-width: 90upx;
			}
		}

		.desc {
			flex: 1;
			font-size: 26upx;
			color: $font-color-dark;
		}
	}

	/* 支付列表 */
	.pay-list {
		padding-left: 40upx;
		margin-top: 16upx;
		background: #fff;

		.pay-item {
			display: flex;
			align-items: center;
			padding-right: 20upx;
			line-height: 1;
			height: 110upx;
			position: relative;
		}

		.icon-weixinzhifu {
			width: 80upx;
			font-size: 40upx;
			color: #6BCC03;
		}

		.icon-alipay {
			width: 80upx;
			font-size: 40upx;
			color: #06B4FD;
		}

		.icon-xuanzhong2 {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 60upx;
			height: 60upx;
			font-size: 40upx;
			color: $base-color;
		}

		.tit {
			font-size: 32upx;
			color: $font-color-dark;
			flex: 1;
		}
	}

	.settlement-section {
		margin-top: 16rpx;
		background-color: #fff;
		width: 100%;
		height: fit-content;
		border-radius: 10px;
		padding-top: 4rpx;
		padding-bottom: 4rpx;
    .section-title{
      font-weight: bold;
      text-align: center;
      font-size: 32rpx;
      .right-button{
        display: inline;
        position: absolute;
        margin-left: 25px;
      }
    }
	}

	.footer {
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 995;
		display: flex;
		align-items: center;
		width: 100%;
		height: 90upx;
		justify-content: space-between;
		font-size: 30upx;
		background-color: #fff;
		z-index: 998;
		color: $font-color-base;
		box-shadow: 0 -1px 5px rgba(0, 0, 0, .1);

		.price-content {
			padding-left: 30upx;
		}

		.price-tip {
			color: $base-color;
			margin-left: 8upx;
		}

		.price {
			font-size: 36upx;
			margin-left: 8upx;
			color: $base-color;
		}

		.submit {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 200upx;
			height: 100%;
			color: #fff;
			font-size: 32upx;
			background-color: $base-color;
		}
	}

	/* 优惠券面板 */
	.mask {
		display: flex;
		align-items: flex-end;
		position: fixed;
		left: 0;
		top: var(--window-top);
		bottom: 0;
		width: 100%;
		background: rgba(0, 0, 0, 0);
		z-index: 9995;
		transition: .3s;

    .invoice-content {
      border-radius: 10px 10px 0 0;
      width: 100%;
      min-height: 30vh;
      max-height: 70vh;
      padding: 30upx;
      background: #fff;
      transform: translateY(100%);
      transition: .3s;
      overflow-y: scroll;
    }

		.mask-content {
			border-radius: 10px 10px 0 0;
			width: 100%;
			min-height: 27vh;
			max-height: 70vh;
			padding: 30upx;
			background: #fff;
			transform: translateY(100%);
			transition: .3s;
			overflow-y: scroll;
		}

		.footer {
			position: absolute;
			bottom: 0;
			left: 0;
			border-top: 1px solid #DCDFE6;

			.confirm {
				background-color: $base-color;
				color: #fff;
				width: 100%;
				height: 70rpx;
				margin: 30rpx 30rpx;
				line-height: 70rpx;
				border-radius: 20px;
				font-size: 15px;
				text-align: center;
			}
		}

		.header {
			margin-bottom: 30upx;
			height: 60rpx;

			.title {
				color: #000;
				display: inline-block;
				font-weight: bold;
				font-size: 17px;
			}

			.close {
				display: inline-block;
				float: right;
				width: 36rpx;
				height: 36rpx;
				margin-top: 12rpx;
			}
		}

		&.none {
			display: none;
		}

		&.show {
			background: rgba(0, 0, 0, .4);

			.mask-content {
				transform: translateY(0);
			}
      .invoice-content {
        transform: translateY(0);
      }
		}
	}

	.payway-area {
		display: flex;
		flex-direction: row;
		align-items: flex-start;
		// background-color: #fff;
		width: 100%;

		.payway-item {
			width: 90px;
			height: 60rpx;
			line-height: 60rpx;
			color: #000;
			text-align: center;
			background-color: #f3f3f3;
			border-radius: 20px;
			margin-right: 10px;
			font-size: 13px;

			&.active {
				background-color: #fff1ef;
				border: 1.5px solid $base-color;
				color: $base-color;
			}

		}
	}

	.integral-area {
		white-space: nowrap;
		// flex-flow: row wrap;
		// align-items: flex-start;
		// justify-content: flex-start;
		// justify-content: space-between;
		// width: 100%;
		margin-top: 30rpx;

		.scroll-wrapper {
			display: flex;
			flex-direction: row;

			.integral-item {
				// width: 30%;
				// height: 30%;
				min-width: 100px;
				min-height: 100rpx;
				color: #000;
				padding: 16rpx;
				text-align: center;
				background-color: #f3f3f3;
				border-radius: 6px;
				margin-right: 30rpx;
				margin-bottom: 20rpx;
				font-size: 12px;
        	.huanhang{
            word-break: break-all;/*属性规定自动换行的处理方法。normal(使用浏览器默认的换行规则。),break-all(允许在单词内换行。),keep-all(只能在半角空格或连字符处换行。)*/
            text-overflow: ellipsis;
            display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
            -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
            -webkit-line-clamp: 1; /** 显示的行数 **/
            overflow: hidden;  /** 隐藏超出的内容 **/
          }
				.name {
					display: block;
					font-size: 12px;
				}

				.balance {
					margin-top: 8rpx;
					display: block;
					font-size: 10px;
				}

				&.active {
					background-color: #fff1ef;
					border: 1px solid $base-color;
					color: $base-color;
				}
			}
		}
	}

	/* 优惠券列表 */
	.coupon-item {
		display: flex;
		flex-direction: column;
		margin: 20upx 24upx;
		background: #fff;

		.con {
			display: flex;
			align-items: center;
			position: relative;
			height: 120upx;
			padding: 0 30upx;

			&:after {
				position: absolute;
				left: 0;
				bottom: 0;
				content: '';
				width: 100%;
				height: 0;
				border-bottom: 1px dashed #f3f3f3;
				transform: scaleY(50%);
			}
		}

		.left {
			display: flex;
			flex-direction: column;
			justify-content: center;
			flex: 1;
			overflow: hidden;
			height: 100upx;
		}

		.title {
			font-size: 32upx;
			color: $font-color-dark;
			margin-bottom: 10upx;
		}

		.time {
			font-size: 24upx;
			color: $font-color-light;
		}

		.right {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size: 26upx;
			color: $font-color-base;
			height: 100upx;
		}

		.price {
			font-size: 44upx;
			color: $base-color;

			&:before {
				content: '￥';
				font-size: 34upx;
			}
		}

		.tips {
			font-size: 24upx;
			color: $font-color-light;
			line-height: 60upx;
			padding-left: 30upx;
		}

		.circle {
			position: absolute;
			left: -6upx;
			bottom: -10upx;
			z-index: 10;
			width: 20upx;
			height: 20upx;
			background: #f3f3f3;
			border-radius: 100px;

			&.r {
				left: auto;
				right: -6upx;
			}
		}
	}
</style>
